<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button class="show">显示下拉框</button>
    <ul hidden class="ul">
        <li>汉语</li>
        <li>英语</li>
        <li>日语</li>
        <li>韩语</li>
        <li>C语</li>
        <li>毛子语</li>
    </ul>
    <script>
        var btn = document.querySelector('.show');
        var ulEl = document.querySelector('.ul');
        // 点击按钮，显示下拉框
        btn.onclick = function(e) {
            ulEl.style.display = 'block';
            // btn冒泡到了body，使得ul又隐藏了,所以需要阻止冒泡
            e.stopPropagation();
            event.cancelBubble=true; // ie浏览器
        }
        // 点击空白，隐藏下拉框
        document.body.onclick = function() {
            ulEl.style.display = 'none';
        }
    </script>
</body>
</html>